<template>
    <el-header>
        <div class="logo">
            <img src="@/assets/images/logo.png" alt="">
        </div>
        <div class="userinfo">
            <span>欢迎您，{{userName}}</span>
            <el-button @click="logout" type="primary" size="mini">退出</el-button>
        </div>
    </el-header>
</template>

<script>
export default {
    data() {
        return {
            userName: ''
        }
    },
    methods: {
        logout() {
            localStorage.clear()
            this.$router.push('/login')
        }
    },
    created() {
        this.userName = localStorage.userName || 'null'
    }
}
</script>

<style>
.el-header {
    background-color: #b3c0d1;
    color: #333;
    line-height: 60px;
    position: fixed;
    top: 0;
    width: 100%;
    height: 60px;
    left: 0;
    z-index: 2;
    padding: 0;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}
.userinfo button {
    margin-left: 15px;
}
.el-header * {
    margin-right: 20px;
    font-size: 14px;
}
.el-header span {
    margin-right: 0;
}
.logo {
    display: inline-block;
    width: 230px;
    text-align: center;
}
.logo img {
    vertical-align: middle;
}
</style>